<!DOCTYPE html>
<html xmlns:th="www.thymeleaf.org" xmlns="">
	<head>
		<meta charset="utf-8">
		<meta name="description" content="大学生就业实训,品质就业,职业规划,IT行业人才基地" />
		<title>蜗牛书城(woniuxy.com)-正品低价、品质保障、配送及时、轻松购物！</title>

		<!-- 引入Bootstrap核心样式文件 -->
		<link th:href="@{/bootstrap-3.4.1/css/bootstrap.min.css}" rel="stylesheet">
		<!-- 引入jQuery核心js文件 -->
		<script th:src="@{/javascript/jQuery-1.12.4.js}"></script>
		<!-- 引入BootStrap核心js文件 -->
		<script th:src="@{/bootstrap-3.4.1/js/bootstrap.min.js}"></script>


		<link rel="shortcut icon" th:href="@{/favicon.ico}" type="image/x-icon" />
		
		<link th:href="@{/css/common.css}" rel="stylesheet" />
		<link th:href="@{/css/top.css}" rel="stylesheet" />
		<link th:href="@{/css/foot.css}" rel="stylesheet" />
		
		<link th:href="@{/css/index.css}" rel="stylesheet" />
		
	</head>
	<body>
		<!--  最顶部的导航栏 -->
		<div th:replace="~{common::top}"></div>
		
		<!--  =================== head =============================== -->
		<div class="head">
			<div class="container">
				<!-- ============= logo ============= -->
				<div class="logo fl">
					<h1>
						<a class="hot-word">蜗牛学苑</a>
					</h1>
				</div>
				<!-- ============= 搜索框部份 ============= -->
				<div class="search fl ml100">
					<div class="up">
						<div class="search-box fl mr18">
							<input class="fl" type="text" value="请输入搜索关键字" />
							<span class="photo">&#xe663;</span>
							<span class="search-icon fl">&#xe660;</span>
						</div>

						<div class="cart fl" style="width: 200px">
							<span class="iconfont">&#xe622;</span>
							<a href="/cart/showCart">我的购物车</a>
							<i class="num" id="cartCount"></i>
							<a href="#" th:onclick="'waitpay('+${session.account.id}+')'">待付款订单</a>
						</div>
					</div>

					<div class="navitems">
						<ol>
							<li><a class="red-and-weight" href="#">秒杀</a></li>
							<li><a class="red-and-weight" href="#">优惠券</a></li>
							<li><a href="#">程序设计</a></li>
							<li><a href="#">数据库</a></li>
							<li><a href="#">网络与数据通信</a></li>
							<li><a href="#">科普读物</a></li>
							<li><a href="#">建筑学</a></li>
						</ol>
					</div>
				</div>
			</div>
		</div>

		<div class="cate-menu container no-padding clear">
			<ul class="fl">
				<li><a href="#">程序设计</a></li>
				<li><a href="#">数据库</a></li>
				<li><a href="#">网络与数据通信</a></li>
				<li><a href="#">科普读物</a></li>
				<li><a href="#">建筑学</a></li>
			</ul>
			<!-- bootstrap轮播图 -->
			<div id="carousel-example-generic" class="carousel slide fl" data-ride="carousel">
				<!-- Indicators -->
				<ol class="carousel-indicators">
					<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
					<li data-target="#carousel-example-generic" data-slide-to="1"></li>
				</ol>

				<!-- Wrapper for slides -->
				<div class="carousel-inner" role="listbox">
					<div class="item active">
						<img th:src="@{/img/banner1.jpeg}" alt="...">
					</div>
					<div class="item">
						<img th:src="@{/img/banner2.jpeg}" alt="...">
					</div>
				</div>

				<!-- Controls -->
				<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
					<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
					<span class="sr-only">Previous</span>
				</a>
				<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
					<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
					<span class="sr-only">Next</span>
				</a>
			</div>
		</div>

		<!-- 中间的广告 -->
		<div class="container no-padding mt15">
			<div class="f clear">
				<div class="ad-box fl">
					<div class="left fl">
						<p><a href="#">古典小说系列</a></p>
						<p><a href="#">九折优惠</a></p>
					</div>
					<div class="right fl">
						<a href="#">
							<img th:src="@{/img/ad1.jpeg}" />
						</a>
					</div>
				</div>

				<div class="ad-box fl">
					<div class="left fl">
						<p><a href="#">古典小说系列</a></p>
						<p><a href="#">九折优惠</a></p>
					</div>
					<div class="right fl">
						<a href="#">
							<img th:src="@{/img/ad2.jpeg}" />
						</a>
					</div>
				</div>

				<div class="ad-box fl">
					<div class="left fl">
						<p><a href="#">古典小说系列</a></p>
						<p><a href="#">九折优惠</a></p>
					</div>
					<div class="right fl">
						<a href="#">
							<img th:src="@{/img/ad3.jpeg}" />
						</a>
					</div>
				</div>

			</div>
		</div>

		<!-- 好书热卖  -->
		<div class="container no-padding mt15">
			<h4>好书热卖</h4>
			<div class="book-box">
				<div class="book-left fl">
					<img th:src="@{/img/new-book.png}"/>
				</div>
				<div class="book-right">
					<ul>
						<li th:each="bookInfo : ${bookInfoListSale}">
							<a th:href="@{|/books/selectBookInfoById?id=${bookInfo.id}|}">
								<img th:src="@{|http://192.168.146.10:8099${bookInfo.bookImg}|}" alt="">
								<p class="book-name">[[${bookInfo.bookName}]]</p>
								<p class="book-price">[[${bookInfo.bookPrice}]]</p>
								
							</a>
						</li>
					</ul>
				</div>
			</div>
		</div>

		<!-- 新书推荐  -->
		<div class="container no-padding mt15">
			<h4>新书推荐</h4>
			<div class="book-box">
				<div class="book-left fl">
					<img th:src="@{/img/new-book.png}" />
				</div>
				<div class="book-right">
					<ul>
						<li>
							<a href="#">
								<img th:src="@{/img/01.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li>
							<a href="#"><img th:src="@{/img/02.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li><a href="#"><img th:src="@{/img/03.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li>
							<a href="#"><img th:src="@{/img/04.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>

						<li class="mt10">
							<a href="#"><img th:src="@{/img/05.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li class="mt10">
							<a href="#"><img th:src="@{/img/06.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li class="mt10">
							<a href="#"><img th:src="@{/img/07.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li class="mt10">
							<a href="#"><img th:src="@{/img/08.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
					</ul>
				</div>
			</div>
		</div>

		<!-- 收藏最多  -->
		<div class="container no-padding mt15">
			<h4>收藏最多</h4>
			<div class="book-box">
				<div class="book-left fl">
					<img th:src="@{/img/collect-book.png}" />
				</div>
				<div class="book-right">
					<ul>
						<li>
							<a href="#">
								<img th:src="@{/img/01.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li>
							<a href="#"><img th:src="@{/img/02.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li><a href="#"><img th:src="@{/img/03.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li>
							<a href="#"><img th:src="@{/img/04.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>

						<li class="mt10">
							<a href="#"><img th:src="@{/img/05.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li class="mt10">
							<a href="#"><img th:src="@{/img/06.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li class="mt10">
							<a href="#"><img th:src="@{/img/07.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
						<li class="mt10">
							<a href="#"><img th:src="@{/img/08.jpg}" alt="">
								<p class="book-name">java核心技术</p>
								<p class="book-price">￥99.00</p>
							</a>
						</li>
					</ul>
				</div>
			</div>
		</div>

		<!-- =============== 最后的网站底部 =============== -->
		<div th:replace="~{common::footer}"></div>
		
	</body>
<script>
	$(function (){
		$.ajax({
			url:'/cart/showCartCount',
			type:'post',
            dataType:'json',
            success:function (json){
                $('#cartCount').html(json.data);
            }
		})
	})
	
	function waitpay(id){
		$.ajax({
			url:'/order/waitPayOrder',
			type:'post',
			data:{
				userId:id,
			},
			dataType:'json',
			success:function (json){
				if(json.code===200){
                    $.each(json.data, function(index,item){
						$.each(item, function(key,value){
							if (key==='id'){
								$.ajax({
									url:'/alipay/query',
									type:'post',
                                    data:{
										out_trade_no:value,
									},
									dataType:'json',
                                    success:function (json){
										const paydata = JSON.parse(json.data);
										console.log(paydata)
										console.log(paydata.alipay_trade_query_response.trade_status)
										if (paydata.alipay_trade_query_response.trade_status=='WAIT_BUYER_PAY'){
											$.ajax({
												url:'/order/updatePayStatus',
												type:'post',
                                                data:{
													id:	json.out_trade_no,
													status:2,
												},
												success:function (json){
													if (json.data===1){
														console.log("状态修改成功")
													}
												}
											})
										}
										//window.location.href="/order/selectWaitOrder?status=2"
										
									}
								})
							}
						})
					})
                }else{
                    alert(json.msg);
                }
			}
		})
	}
</script>
</html>
